clear
%oad ../parameter_sandbox_ces/eq_mit_mass.mat 
load ../free_entry_frictionless/eq_mit_entry.mat
%load ../prod/calibration_v3/sandbox_ces/eq_mit_mass.mat
eq_mit_ces = eq_mit;

clearvars -except eq_mit_ces

%load ../parameter_sandbox_wage_rule/eq_mit_mass.mat 
load ../free_entry/eq_mit_entry.mat
%load ../prod/calibration_v3/sandbox/eq_mit_mass.mat

%% get actual data - mass of firms

%Ns = [1, 1 - .04];% + [0.0000000 -0.7654149 -4.1384743 -5.6245749 -6.4591448 -5.1005793 -4.2323999]/100;
Ns = 1 - [7.13]/100;

prods = repmat(exp(glob.sf(:,2)), 1, options.T);

%% pick scaling coefficients

adj = sum(eq_mit.mu,1);
scx = pick_scale(adj, Ns);

mass = sum(eq_mit.mu,1);
Ns = log_linear_scale(mass, scx)/mass(end);
Ns = Ns(1:50);

adj = sum(eq_mit_ces.mu,1);

scx_ces = pick_scale(adj, Ns);
%scx_ces = [0 -diff(Ns-1)]/scx;


%% compute cost-weighted markups
ngdp = sum(eq_mit.mu.*eq_mit.p.*eq_mit.y);
labor_bill = eq_mit.W'.*sum(eq_mit.l.*eq_mit.mu);
labor_share = (labor_bill./ngdp);

ngdp = sum(eq_mit_ces.mu.*eq_mit_ces.p.*eq_mit_ces.y);
labor_bill = eq_mit_ces.W'.*sum(eq_mit_ces.l.*eq_mit_ces.mu);
labor_share_ces = (labor_bill./ngdp);


%%
set(0,'defaultaxesfontname','cambria math') % beautify the axes a bit
set(0,'defaultTextFontName', 'cambria math')


close all

T = 15;

labor_share = 1./labor_share;
labor_share_ces = 1./labor_share_ces;

plot((log_linear_scale_plot(labor_share, scx)), 'LineWidth', 4); xlim([1 T]); 
hold on
plot((log_linear_scale_plot(labor_share_ces, scx_ces)), 'r-.', 'LineWidth', 4); xlim([1 T]); 
ytickformat('percentage')
yline(0, '--')


legend('Adjustment Costs', 'No Adjustment Costs')
set(findall(gcf,'-property','FontSize'),'FontSize',12)
set(gcf,'units','points','position',[10,10,500,300])

print('-dpng', 'figures/adj_cost_reallocation.png')



